package com.myown.jdk.design.impl;

import com.myown.jdk.design.Communication;

/**
 * 装修模式 <p>
 *
 * 装饰模式就是给一个对象增加一些新的功能，而且是动态的，要求装饰对象
 * 和被装饰对象实现同一个接口，装饰对象持有被装饰对象的实例
 *
 * @author lincky
 * @version v1.0.0
 * @time 2017.03.24 15:24
 */
public class CommunicationDecorator implements Communication {

    private Communication communication;

    public CommunicationDecorator(Communication communication) {
        this.communication = communication;
    }

    @Override
    public void send() {
        System.out.println("before send");
        communication.send();
        System.out.println("before send");
    }

    @Override
    public void receive() {
        System.out.println("before receive");
        communication.receive();
        System.out.println("before receive");
    }
}
